﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Framework.Validation.Implementation
{
    /// <summary>
    /// Contains <see cref="IValidationResult" /> items.
    /// </summary>
    public class ValidationResults : ICollection<IValidationResult>, IValidationResults
    {
        private readonly ICollection<IValidationResult> collection =
            new Collection<IValidationResult>();

        /// <inheritdoc />
        public IEnumerator<IValidationResult> GetEnumerator()
        {
            return collection.GetEnumerator();
        }

        /// <inheritdoc />
        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        /// <inheritdoc />
        public void Add(IValidationResult item)
        {
            collection.Add(item);
        }

        /// <inheritdoc />
        public void Clear()
        {
            collection.Clear();
        }

        /// <inheritdoc />
        public bool Contains(IValidationResult item)
        {
            return collection.Contains(item);
        }

        /// <inheritdoc />
        public void CopyTo(IValidationResult[] array, int arrayIndex)
        {
            throw new NotImplementedException();
        }

        /// <inheritdoc />
        public bool Remove(IValidationResult item)
        {
            return collection.Remove(item);
        }

        /// <inheritdoc />
        public int Count
        {
            get
            {
                return collection.Count;
            }
        }

        /// <inheritdoc />
        public bool IsReadOnly
        {
            get
            {
                return false;
            }
        }

        /// <inheritdoc />
        public bool IsValid
        {
            get
            {
                return collection.Count == 0;
            }
        }
    }
}
